﻿<div class="content-wrapper">
    <section class="content-header">
        <h1>
            仓库管理
            <small>库存记录</small>
        </h1>
        <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> 首页</a></li>
            <li><a href="#">仓库管理</a></li>
            <li class="active">盘库记录</li>
        </ol>
    </section>
    <section class="content">
        <div class="row" style="padding-bottom:1px;">
            <div class="col-md-12">
                <div class="box">
                    <div class="box-body">
                        <div class="input-group">
                            <span class="input-group-addon">日期范围</span>
                            <input type="text" ref="datemin" id="datemin" class="form-control" style="width:120px;">
                            <input type="text" ref="datemax" id="datemax" class="form-control" style="width:120px;margin-left:10px;">
                            <button name="search" v-on:click="searchL" type="submit" class="btn btn-success" style="margin-left:10px;"><i class="fa fa-search"></i> 查询</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-xs-12">
                <div class="box">
                    <div class="box-body">
                        <div id="toolbar" class="btn-group">
                            <button id="btn_add" v-on:click="showDetail" type="button" class="btn btn-default">
                                <span class="glyphicon glyphicon-plus" aria-hidden="true"></span>详情
                            </button>
                        </div>
                        <table id="bootstraptable" class="table table-bordered text-nowrap table-hover"></table>
                    </div>
                </div>
            </div>
        </div>
    </section>
</div>
@section scripts{
    <script type="text/javascript">
        var app = new Vue({
            el: '#app',
            data: {
                datemin: '',
                datemax: '',
            },
            mounted: function () {
                var _self = this;
                _self.$nextTick(function () {
                    //显示active
                    _self.$refs.InventoryRecord.parentNode.parentNode.classList.add("active");
                    _self.$refs.InventoryRecord.classList.add("active");
                    _self.$refs.datemin.value = _self.getCurrentMonthFirst();
                    _self.$refs.datemax.value = _self.getCurrentMonthLast();

                    $('#datemin').datetimepicker({
                        format: 'yyyy-mm-dd',
                        minView: 2,
                        autoclose: true,
                        language: "zh-CN"
                    });

                    $('#datemax').datetimepicker({
                        format: 'yyyy-mm-dd',
                        minView: 2,
                        autoclose: true,
                        language: "zh-CN"
                    });
                    setTimeout(function () {
                        _self.loadL();
                    }, 500);
                });
            },
            methods: {
                loadL: function () {
                    _self = this;
                    var obj = [{
                        checkbox: true,             //是否显示复选框
                        visible: true
                    },
                    {
                        field: 'PatchId',
                        title: 'Id',
                        visible: false
                    }, {
                        field: 'CName',
                        title: '创建人',
                        align: 'center',
                        sortable: true
                    }, {
                        field: 'CreateDate',
                        align: 'center',
                        title: '创建时间',
                        sortable: true,
                        formatter: function (value, row, index) {
                            return _self.jsonDateFormat(value);
                        }
                    }];

                    yui.table("bootstraptable", obj, tblConfigExt);
                },
                searchL: function () {
                    $("#bootstraptable").bootstrapTable('refresh');
                },
                showDetail: function () {
                    var arr = $("#bootstraptable").bootstrapTable('getSelections');
                    if (arr.length > 0) {
                        var id = arr[0].PatchId;
                        yui.layershow("盘库明细", "/InventoryRecord/Detail?id=" + id, 600, 650);
                    } else {
                        layer.alert("请选中行", { icoon: 3, skin: "layer-ext-moon" });
                    }
                    
                }
            }
        });

        var tblConfigExt = {
            url: "/InventoryRecord/List",
            method: "POST",
            queryParams: function () {  // 查询时，需要传递的参数
                var params = this;
                var temp = {
                    limit: params.pageSize,     //页面大小
                    offset: params.pageSize * (params.pageNumber - 1),   //页码
                    sort: params.sortName,      //排序列名
                    order: params.sortOrder, //排序命令（desc，asc）
                    search: app.$data.search
                };
                return temp;
            },
            singleSelect: false,  //设置 true 将禁止多选。
            sortOrder: "desc", // 排序方式
            sortName: "CreateDate", // 排序字段
            uniqueId: "PatchId" //每一行的唯一标识，一般为主键列
        };
    </script>
}